package top.leix.springdemo;

import lombok.Data;

import java.io.Serializable;

@Data
public class Res implements Serializable {
    private static final long serialVersionUID = 1L;
    private String code;
    private String msg;
    private Object data;

    public static Res ok(Object data){
        Res r = new Res();
        r.code = "200";
        r.data = data;
        r.msg = "成功";
        return r;
    }
    public static Res failed(Object data){
        Res r = new Res();
        r.code = "500";
        r.msg = "失败";
        r.data = data;
        return r;
    }
    public static Res failed(String msg){
        Res r = new Res();
        r.code = "500";
        r.msg = msg;
        r.data = null;
        return r;
    }

    public static Res setCodeAndMsg(String code, String msg){
        Res r = new Res();
        r.code = code;
        r.msg = msg;
        return r;
    }
}
